package net.wantongtech.xa.uploadbasicinfo.service;

import cn.com.taiji.sdk.comm.LwClientHelper;
import cn.com.taiji.sdk.model.comm.protocol.cdts.etcts.EtcClearDownloadRequest;
import lombok.extern.slf4j.Slf4j;
import net.wantongtech.xa.uploadbasicinfo.config.SCPClientConfig;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;

/**
 * 下载清分包
 *
 * @author MaShibo
 * 日期 :  2020/3/4
 */
@Slf4j
@Service
public class DownloadClearPackageService {

    @Resource
    private SCPClientConfig scpClientConfig;

    public void download() {
        EtcClearDownloadRequest request = new EtcClearDownloadRequest();
        request.setClearDate("2020-02-09");
        String fileName = LwClientHelper.prepareFilename(request);
        log.info("请求文件名：{}", fileName);
        File rspFile;
        try {
            rspFile = LwClientHelper.downLoad(request, scpClientConfig.getLocalStorePath());
            log.info("响应文件：{}", rspFile);
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
    }

}
